﻿using Nova_BLL;
using Nova_Common.Extend;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web.Http;
using WMS_Api.App_Start;
using WMS_Api.Areas.RFSystem.Models;
using WMS_Api.Controllers;
using WMS_Api.Models;

namespace WMS_Api.Areas.RFSystem.Controllers
{
    /// <summary>
    ///  手持公共接口
    /// </summary>
    [RoutePrefix("api/RFSystem/Commom")]
    [ControllerGroup("PDA手持", "公共功能接口")]
    public class CommonController : BaseApiController
    {
        /// <summary>
        /// 获取尺寸信息
        /// </summary>
        /// <returns></returns>
        [HttpGet, Route("GetSizeList")]
        public ApiResult GetSizeList()
        {
            TSizeDefineMainBll bll = new TSizeDefineMainBll();
            var list = bll.GetList();
            return Success("获取托盘尺寸列表!", list);
        }

        /// <summary>
        /// 根据托盘码获取托盘尺寸
        /// </summary>
        /// <param name="trayId"></param>
        /// <returns></returns>
        [HttpGet, Route("GetTraySize")]
        public ApiResult GetSizeByTrayId(string trayId)
        {
            TRelationsBll bll = new TRelationsBll();
            var model = bll.GetEntityByTrayId(trayId);
            return Success("获取托盘尺寸信息!", model.IsEmpty() ? 0 : model.TypeOfSize);
        }

        /// <summary>
        /// 根据托盘码获取托盘尺寸
        /// </summary>
        /// <param name="trayId"></param>
        /// <returns></returns>
        [HttpGet, Route("GetSizeByTrayIdV")]
        public ApiResult GetSizeByTrayIdV(string trayId)
        {
            TRelationsBll bll = new TRelationsBll();
            TSizeDefineMainBll sizeBll = new TSizeDefineMainBll();
            var model = bll.GetEntityByTrayId(trayId);
            var list = sizeBll.GetList();
            return Success("获取托盘尺寸列表!", new { TraySize = model.IsEmpty() ? 0 : model.TypeOfSize, SizeList = list });
        }

        /// <summary>
        /// 获取特殊物料类型-物料归属组
        /// </summary>
        /// <returns></returns>
        [HttpGet,Route("GetMaterialGroupTypeList")]
        public ApiResult  GetMaterialGroupTypeList()
        {
            TMaterialGroupInfoBll bll = new TMaterialGroupInfoBll();
            var list = bll.GetListByGroupType(1);
            return Success("获取特殊物料类型集合!", list);
        }

    }
}
